package com.atlinmengze.java.ai.langchain4j.tools;

import dev.langchain4j.agent.tool.P;
import dev.langchain4j.agent.tool.Tool;
import org.springframework.stereotype.Component;

@Component
public class CalculatorTools {
    /**
     * 两个数求和
     * @param a
     * @param b
     * @return
     */
    @Tool(name = "加法",value = "获取两数之和")
    double sum(@P(value = "第一个加数",required = true)double a, @P(value = "第二个加数",required = true)double b) {
        System.out.println("调用加法运算");
        return a + b;
    }

    /**
     * 获取平方根
     * @param x
     * @return
     */
    @Tool(name="获取平方根",value = "获取一个数的平方根")
    double squareRoot(@P(value ="需要获取平方根的数",required = true)double x) {
         System.out.println("调用平方根运算");
        return Math.sqrt(x);
    }
}